package com.taijia.chapter8;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * FileOutputStreamTest
 * 
 * @author taijia
 * @since 2014年11月25日
 *
 */
public class FileOutputStreamTest {
	public static void main(String[] args) {
		int b = 0;
		FileInputStream fis = null;
		FileOutputStream fos = null;
			try {
				fis = new FileInputStream("E:/myeclipse2014/Workspaces/2014/msb_basic/src/com/taijia/chapter8/FileInputStreamTest.java");
				fos = new FileOutputStream("E:/myeclipse2014/Workspaces/2014/msb_basic/src/com/taijia/chapter8/FileOutputStreamTest.txt");
				while ((b = fis.read()) != -1) {
					fos.write(b);
				}
				System.out.println("文件复制成功！");
			} catch (FileNotFoundException e) {
				e.printStackTrace();
				System.exit(-1);
			} catch (IOException e) {
				e.printStackTrace();
				System.exit(-1);
			} finally {
				try {
					fis.close();
					fos.close();
				} catch (IOException e) {
					e.printStackTrace();
					System.exit(-1);
				}
			}
	}
}
